home *** CD-ROM | disk | FTP | other *** search
- ;
- ; This is file: RAWMODE.MAC
- ;
- page 60,132
- title RAWMODE.MAC
- subttl Routines to manipulate console raw mode.
- ;
- ; Written by Mark Hersey
- ; Hersey Micro Consulting, Inc.
- ;
- ; This program is public domain. No copyrights reserved.
- ;
- ; The purpose of these subroutines is to allow your program
- ; to use raw console output, which is faster than the
- ; normal (cooked or ASCII) mode. When the console is in cooked
- ; mode, MS-DOS checks for console input (specifically looking
- ; for Ctrl-C == Ctrl-Break) with every character
- ; that is written to the screen. In raw mode, it will not.
- ;
- ; You may need to change the procedure names to match
- ; the requirements of your compiler.
- ; You may need to change the segment and group names to match
- ; those used by your compiler.
- ;
- pgroup group prog
- dgroup group data
-
- data segment byte public 'data'
- assume nothing
-
- saved_mode db ?
-
- assume nothing
- data ends
-
- prog segment byte public 'prog'
- assume cs:pgroup,ds:dgroup
- ;
- ; raw_mode - Save old mode and put console device into raw mode.
- ;
- ; Inputs:
- ; None
- ; Outputs:
- ; [saved_mode] has old mode in it.
- ; Console is in raw mode.
- ; Comments:
- ; Call once at the start of your program.
- ;
- raw_mode proc near
- public raw_mode
-
- mov ah,044h ;I/O-Control call for devices.
- mov al,000h ;Get device information.
- mov bx,001h ;File handle for CON: output.
- int 021h ;Make MS-DOS call.
- mov [saved_mode],dl ;Save old mode.
- mov ah,044h ;I/O-Control call for devices.
- mov al,001h ;Set device information.
- mov bx,001h ;File handle for CON: output.
- xor dh,dh ;Must be zero.
- or dl,020h ;Set raw mode bit, leave others same.
- int 021h ;Make MS-DOS call.
- ret
-
- raw_mode endp
- ;
- ; old_mode - Save old mode and put console device into raw mode.
- ;
- ; Inputs:
- ; [saved_mode] has old mode in it.
- ; Outputs:
- ; Console is set to [saved_mode].
- ; Comments:
- ; Call once at the end of your program.
- ;
- old_mode proc near
- public old_mode
-
- mov ah,044h ;I/O-Control call for devices.
- mov al,001h ;Set device information.
- mov bx,001h ;File handle for CON: output.
- xor dh,dh ;Must be zero.
- mov dl,[saved_mode] ;Get old mode.
- int 021h ;Make MS-DOS call.
- ret
-
- old_mode endp
-
- assume nothing
- prog ends
-
- end